﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace JumpstartApp.Models
{
    [XmlRoot(ElementName = "Episode")]
    public class EpisodeRecord : ChildBase
    {
        private string m_Date = string.Empty;
        [XmlElement("Date")]
        public string Date
        {
            get
            {
                DateTime _Date;
                if (DateTime.TryParse(m_Date, out _Date))
                    return _Date.ToString("MMMM dd, yyyy");
                return m_Date;
            }
            set { m_Date = value; }
        }
        public DateTime DateTime
        {
            get
            {
                DateTime _Date;
                if (DateTime.TryParse(m_Date, out _Date))
                    return _Date;
                return DateTime.MinValue;
            }
        }

        private string m_Image = string.Empty;
        [XmlElement("Image")]
        public new string Image
        {
            get
            {
                if (string.IsNullOrEmpty(m_Image))
                    return this.Video.Replace(".mp4", "_512.jpg");
                return m_Image;
            }
            set { m_Image = value; }
        }

        //[XmlIgnore]
        //public string Notes
        //{
        //    get
        //    {
        //        return App.EpisodeNotes[this.Id];
        //    }

        //    set
        //    {
        //        App.EpisodeNotes[this.Id] = value;
        //    }
        //}

        public override ChildBase Clone()
        {
            return new EpisodeRecord()
            {
                Id = this.Id,
                Description = this.Description,
                Image = this.Image,
                Index = this.Index,
                Link = this.Link,
                Title = this.Title,
                Video = this.Video,
                Date = this.Date,
            };
        }

    }
}
